<template>
   
</template>

<script setup>
import { showNotify } from "vant";
import { onMounted,getCurrentInstance } from "vue";

const {proxy} = getCurrentInstance(); 

const userId = ref(null);
const addressList = ref([]);

 const getAddressByUserId = ()=>{
    proxy.$axios({
        method:'get',
        url: '/address/user/'+userId.value
    }).then(res=>{
        let resultBean = res.data;
        if(resultBean.code == 200){
            addressList.value = resultBean.data;
        }else{
            showNotify({message: resultBean.msg});
        }
    }).catch(error=>{
        showNotify({message: error.message});
    })
 }

 onMounted(()=>{
    //传递参数或者从本地存储自行获取
    console.log('用户id', proxy.$route.params.userId);
    //获取用户id
    userId.value = proxy.$route.params.userId

    getAddressByUserId();
    
 })

</script>

<style>
</style>